package com.lkx.farmershop.controller;

import com.lkx.farmershop.common.api.ApiResult;
import com.lkx.farmershop.model.dto.CommentsDto;
import com.lkx.farmershop.model.vo.CommentsVo;
import com.lkx.farmershop.service.CommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    /**
     * 添加评论
     * @param commentsDto
     * @return
     */
    @PostMapping("/addComments")
    public ApiResult<String> addComments(@RequestBody CommentsDto commentsDto) {
        return commentsService.addComments(commentsDto);
    }

    /**
     * 获取评论列表
     * @param tuanId
     * @return
     */
    @GetMapping("/getCommentsList")
    public ApiResult<List<List<CommentsVo>>> getCommentsList(@RequestParam("tuanId") Long tuanId) {
        return commentsService.getCommentsList(tuanId);
    }

}
